package com.shawn.springboot.integeration.netty.client.initializer;

import com.shawn.springboot.integeration.netty.client.handler.ClientHandler;
import com.shawn.springboot.integeration.netty.codec.RpcDecoder;
import com.shawn.springboot.integeration.netty.codec.RpcEncoder;
import com.shawn.springboot.integeration.netty.msg.Request;
import com.shawn.springboot.integeration.netty.msg.Response;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @author zhangjian
 * @title: DefaultChannelInitializer
 * @projectName 12-springboot学习
 * @description: 默认通道设置器
 * @date 2021/4/289:22
 */
public class DefaultChannelInitializer extends AbstractChannelInitializer{
    @Override
    public ByteToMessageDecoder getDecoder() {
        return new RpcDecoder(Response.class);
    }

    @Override
    public MessageToByteEncoder getEncoder() {
        return new RpcEncoder(Request.class);
    }

    @Override
    public ChannelInboundHandlerAdapter getClientHandler() {
        return new ClientHandler();
    }
}
